<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" onkeyup="myOnkeyup(event)">
</body>
<script>
    //1.获取事件源
    let input = document.querySelector('input')
    //2.绑定事件类型(此处为点击事件)
    //3.函数设定事件处理程序
    input.onkeydown = function (event) {
           console.log("键盘正在按下");
           if(event.shiftKey)
           {
             alert("shift键被按下")
           }
           let a = event.keyCode;
           let b = String.fromCharCode(a);
           console.log(b);
        }
    function myOnkeyup(event) {
        let a = event.keyCode;
        let b = String.fromCharCode(a);
        console.log(b+"按键被抬起");
        
    }
    // button.onclick = function () {
    //     alert("hello world");
    // }
</script>
</html>